﻿namespace WMS6.Web.Inventory
{
    using System;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;
    using WMS6.Web.StockCountServiceRef;

    public class CCRelease : BasePage
    {
        protected Button btnRelease;
        protected Button btnSave;
        protected CheckBox chkInclZeroCount;
        protected CheckBox chkRequestOnly;
        protected CheckBox chkShowQty;
        protected HtmlForm F5510;
        protected HtmlInputHidden hdnCcCriteriaID;
        protected HtmlHead Head1;
        protected Label lblAllocateRule;
        protected Label lblDay;
        protected Label lblLocSelect;
        protected Label lblMsg;
        protected Label lblQty;
        protected Label lblQty1;
        protected HtmlLink mycss;
        protected Label one1;
        protected ScriptManager ScriptManager1;
        protected TextBox txtDay;
        protected TextBox txtLocSelect;
        protected TextBox txtMaxCounts;
        protected TextBox txtQtyLessThan;
        protected UpdatePanel up1;

        protected void btnRelease_Click(object sender, EventArgs e)
        {
            string strValue = string.Empty;
            CycleCountCriteriaInfo cycleCountCriteriainfo = new CycleCountCriteriaInfo {
                CcCriteriaID = this.hdnCcCriteriaID.Value,
                LocSelection = this.txtLocSelect.Text,
                MaxCounts = Convert.ToInt32(this.txtMaxCounts.Text)
            };
            if (!string.IsNullOrEmpty(this.txtQtyLessThan.Text))
            {
                cycleCountCriteriainfo.QtyLessThan = Convert.ToDecimal(this.txtQtyLessThan.Text);
            }
            else
            {
                cycleCountCriteriainfo.QtyLessThan = 0M;
            }
            cycleCountCriteriainfo.RequestOnly = this.chkRequestOnly.Checked ? "Y" : "N";
            cycleCountCriteriainfo.ShowQty = this.chkShowQty.Checked ? "Y" : "N";
            cycleCountCriteriainfo.InclZeroCount = this.chkInclZeroCount.Checked ? "Y" : "N";
            try
            {
                strValue = StockCountServiceClientProxy.GetInstance().CycleCountRelease(cycleCountCriteriainfo);
                this.lblMsg.Text = strValue + base.GetGlobalMsgResource("F5720_001");
            }
            catch (Exception ex)
            {
                this.lblMsg.Text = ex.Message;
            }
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strCriteriaID = string.Empty;
            CycleCountCriteriaInfo cycleCountCriteriainfo = new CycleCountCriteriaInfo {
                CcCriteriaID = "",
                LocSelection = this.txtLocSelect.Text,
                MaxCounts = Convert.ToInt32(this.txtMaxCounts.Text),
                QtyLessThan = Convert.ToDecimal(this.txtQtyLessThan.Text),
                RequestOnly = this.chkRequestOnly.Checked ? "Y" : "N",
                ShowQty = this.chkShowQty.Checked ? "Y" : "N",
                InclZeroCount = this.chkInclZeroCount.Checked ? "Y" : "N"
            };
            try
            {
                strCriteriaID = StockCountServiceClientProxy.GetInstance().SetCycleCountCriteria(cycleCountCriteriainfo);
                this.hdnCcCriteriaID.Value = strCriteriaID;
                this.lblMsg.Text = base.GetGlobalMsgResource("C004");
            }
            catch (Exception ex)
            {
                this.lblMsg.Text = ex.Message;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            base.InitPage(this.Page);
        }
    }
}

